home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / wind5x.arc / WNDWMGR.PAS < prev    next >
Pascal/Delphi Source File  |  1991-01-09  |  10KB  |  314 lines

  1. { =========================================================================== }
  2. { WndwMgr.pas - Multi-level Virtual Window demo             ver 5.X, 12-20-88 }
  3. {               to demonstrate powerful window management.                    }
  4. {                                                                             }
  5. { This program shows you how the window management utilities allow you to     }
  6. { access any window at any time.  You can even hide the top level window for  }
  7. { displaying later.                                                           }
  8. {   The demo places a very heavy load on screen processing by doing full      }
  9. { screen scrolling on the virtual screens and then updating them on the CRT.  }
  10. { Notice that the full windows are updated even if covered.  The constantly   }
  11. { scrolling screens are there just to make it more apparent where and how     }
  12. { fast the windows are being updated.                                         }
  13. {   Run program.  Instructions are on the screen.                             }
  14. {   Copyright (C) 1987,1988 by James H. LeMay,  All rights reserved.          }
  15. { =========================================================================== }
  16. program ManagementDemo;
  17.  
  18. {$M 16384, 50000, 50000 }
  19. { R-,S-,I-,D-,T-,F-,V-,B-,N-,L+ }       { TP4 directives }
  20. {$A-,B-,D-,E-,F-,I-,L-,N-,O-,R-,S-,V-}  { TP5 directives }
  21.  
  22. uses
  23.   Crt,Qwik,Wndw,Keyb,Goof;
  24.  
  25. type
  26.   Str80 = string[80];
  27.  
  28. const
  29.   StrA: array[1..25] of Str80 = (
  30.     '╓──────────────────────────────────────────────────────────╖',
  31.     '╙─╥────────── E A G L E  Performance Software ───────────╥─╜',
  32.     '  ╙─╥───── P.O. Box 122237, Ft. Worth, TX  76121 ──────╥─╜',
  33.     '    ╙──────────────────────────────────────────────────╜',
  34.     'WNDW5X.TPU  gives  you  unparalleled  performance in  window',
  35.     'software for  Turbo Pascal 5.0.  It features fixed, hiddden,',
  36.     'and true virtual windows with true random-access.   Now your',
  37.     'windows can be dynamically updated even if they are covered!',
  38.     'The  speed of  hidden and  virtual screens is phenomenal  as',
  39.     'they use the virtual writing routines of QWIK5X.TPU.',
  40.     '',
  41.     'RANDOM ACCESS  is the power to  pull any  window  to the top',
  42.     'even  if they  are covered without  shuffling!   This  means',
  43.     'your  windows  can be in any order  and not  just stacked or',
  44.     'tiled.',
  45.     '',
  46.     'VIRTUAL WINDOWS -  The screens for virtual windows can be of',
  47.     'any  row  and  column  size in  a 64k buffer.  The  rows and',
  48.     'columns  can  range  from 1 to 255.  These  windows  can  be',
  49.     'resized, zoomed, or scrolled right on the screen!',
  50.     '',
  51.     'Programmers  will find the code very easy to use and simple.',
  52.     'All  the  hard  working  code is  kept transparent.  Several',
  53.     'window-relative and window management routines are included.',
  54.     '');
  55.  
  56.   { ASCII Key codes: }
  57.   Alt1     = #120;
  58.   Alt2     = #121;
  59.   Alt3     = #122;
  60.   Alt4     = #123;
  61.   LArr     = #75;
  62.   RArr     = #77;
  63.   UArr     = #72;
  64.   DArr     = #80;
  65.   HomeKey  = #71;
  66.   EndKey   = #79;
  67.   PgUp     = #73;
  68.   PgDn     = #81;
  69.   EscKey   = #27;
  70.   RetKey   = #13;
  71.   F5Key    = #63;
  72.   F10Key   = #68;
  73.  
  74.   ScrollLock = $10;
  75.   MoveMode   = $01;
  76.   ResizeMode = $02;
  77.   ScrollMode = $04;
  78.   AlterMode: byte = MoveMode;
  79.  
  80. var
  81.   RowStep,ColStep,i,Line,
  82.   FastRowStep,FastColStep: byte;
  83.   NumOfRows,NumOfCols:     integer;
  84.   Name:                    WindowNames;
  85.   Key:                     char;
  86.   ExtKey,Typematic:        boolean;
  87.  
  88. function ScrollLockOn: boolean;
  89. begin
  90.   ScrollLockOn:=((KeyStatus and ScrollLock)<>0);
  91. end;
  92.  
  93. procedure UpdateKeyStatus;
  94. var S: string[20];
  95. begin
  96.   if ScrollLockOn then
  97.     begin
  98.       if not VirtualFlag then AlterMode:=MoveMode;
  99.       Qwrite (CRTrows,61,White+GreenBG,#24#25#27#26);
  100.       case AlterMode of
  101.         MoveMode:   S:='-Move   ';
  102.         ResizeMode: S:='-Resize ';
  103.         ScrollMode: S:='-Scroll ';
  104.       end;
  105.       QwriteEos (Black +GreenBG,S);
  106.       QwriteEos (Yellow+GreenBG,' SCROLL');
  107.     end
  108.   else Qfill (CRTrows,61,1,20,GreenBG,' ');
  109. end;
  110.  
  111. { For this demo, not only are the windows being scrolled on the screen, }
  112. { but also in RAM whether they are seen or not!  So, let's give it a    }
  113. { heavy CPU and video load, but still see how fast it can go. }
  114. procedure UpdateWindows;
  115. begin
  116.   WriteToVirtual (Name);
  117.   WscrollUp;                 { For the heaviest load, scroll up entire screen }
  118.   WWrite (25,2,StrA[Line]);  { Wrap a new line at the bottom }
  119.   VUpdateWindow;
  120.   inc (Name);
  121.   if Name=Window4 then
  122.     begin
  123.       Name := Window1;
  124.       inc (Line);
  125.       Line := succ(pred(Line) mod 25);
  126.     end;
  127. end;
  128.  
  129. { Here's where the windows are updated!  When the keyboard is idle, the  }
  130. { following procedure is run.  You may change the contents of course.    }
  131. {$F+}
  132. procedure KbdIdle;
  133. begin
  134.   UpdateWindows;
  135.   WriteToCRT;
  136.   UpdateKeyStatus;
  137. end;
  138. {$F-}
  139.  
  140. procedure InitStepRates;
  141. begin
  142.   if CRTrows>40 then
  143.        FastRowStep:=4
  144.   else FastRowStep:=2;
  145.   FastColStep:=CRTcols div 20;
  146. end;
  147.  
  148. procedure AdjustStepRates;
  149. begin
  150.   if Typematic then
  151.     begin
  152.       ColStep:=FastColStep;
  153.       RowStep:=FastRowStep;
  154.     end
  155.   else
  156.     begin
  157.       ColStep:=1;
  158.       RowStep:=1;
  159.     end;
  160. end;
  161.  
  162. procedure GetSteps (VAR NumOfRows,NumOfCols: integer);
  163. var Rows,Cols: integer;
  164. begin
  165.   AdjustStepRates;
  166.   Rows:=0;
  167.   Cols:=0;
  168.   case Key of
  169.     UArr:    Rows :=-RowStep;
  170.     DArr:    Rows := RowStep;
  171.     LArr:    Cols :=-ColStep;
  172.     RArr:    Cols := ColStep;
  173.     PgUp:    Rows :=-255;
  174.     PgDn:    Rows := 255;
  175.     HomeKey: Cols :=-255;
  176.     EndKey:  Cols := 255;
  177.   end;
  178.   NumOfRows := Rows;
  179.   NumOfCols := Cols;
  180. end;
  181.  
  182. procedure AlterWindow;
  183. var Rows,Cols: integer;
  184. begin
  185.   if not VirtualFlag then AlterMode:=MoveMode;
  186.   if ExtKey then
  187.     begin
  188.       GetSteps (Rows,Cols);
  189.       case AlterMode of
  190.         MoveMode:    MoveWindow    (Rows,Cols);
  191.         ResizeMode:  VResizeWindow (Rows,Cols);
  192.         ScrollMode:  VScrollView   (Rows,Cols);
  193.       end;
  194.     end
  195.   else
  196.     if VirtualFlag then
  197.       case Key of
  198.         'M','m': AlterMode:=MoveMode;
  199.         'R','r': AlterMode:=ResizeMode;
  200.         'S','s': AlterMode:=ScrollMode;
  201.       end;
  202. end;
  203.  
  204. procedure CreateScreen;
  205. begin
  206.   InitWindow (Yellow+BlackBG,true);
  207.   SetVirtualSize (25,80);   { To keep heap limited }
  208.   TitleOfs := 0;            { Place titles at extreme left or right }
  209.   with Margins do
  210.     begin
  211.     { TopMargin:=2; }
  212.       BottomMargin:=pred(CRTrows);
  213.     { RightMargin:=79;
  214.       Leftmargin:=2; }
  215.     end;
  216.   Qfill (CRTrows,1,1,CRTcols,GreenBG,' ');
  217.   Qwrite (CRTrows,2,White+GreenBG,'Alt:1-4');
  218.   QwriteEos (Black+GreenBG,'-Window Num  ');
  219.   QwriteEos (White+GreenBG,'ESC');
  220.   QwriteEos (Black+GreenBG,'-Hide  ');
  221.   QwriteEos (White+GreenBG,'F5');
  222.   QwriteEos (Black+GreenBG,'-Zoom  ');
  223.   QwriteEos (White+GreenBG,'F10');
  224.   QwriteEos (Black+GreenBG,'-Quit  ');
  225.   InitStepRates;
  226.   SetWindowModes ({ZoomMode or} CursorOffMode or VirtualMode);
  227.  
  228.   { -- Virtual Window 1 -- }
  229.   MakeWindow ( 1, 1,20,60,Black+BrownBG,Black+BrownBG,SingleBrdr,Window1);
  230.   WriteToVirtual (TWS.WSname);
  231.   TitleWindow (Top,Left,White+BrownBG,'1 Virtual Window ');
  232.   for i:=1 to 25 do WWrite (i,2,StrA[i]);
  233.   VUpdateWindow;
  234.  
  235.   { -- Virtual Window 2 -- }
  236.   WriteToCRT;
  237.   MakeWindow ( 6,10,16,60,White+GreenBG,White+GreenBG,SingleBrdr,Window2);
  238.   WriteToVirtual (TWS.WSname);
  239.   TitleWindow (Top,Left,Yellow+GreenBG,'2 Virtual Window  ');
  240.   for i:=1 to 25 do WWrite (i,2,StrA[i]);
  241.   VUpdateWindow;
  242.  
  243.   { -- Virtual Window 3 -- }
  244.   WriteToCRT;
  245.   MakeWindow (11,20,14,59,White+BlueBG,White+BlueBG,SingleBrdr,Window3);
  246.   WriteToVirtual (TWS.WSname);
  247.   TitleWindow (Top,Left,Yellow+BlueBG,'3 Virtual Window  ');
  248.   for i:=1 to 25 do WWrite (i,2,StrA[i]);
  249.   VUpdateWindow;
  250.  
  251.   { -- Fixed Window 4 -- }
  252.   WriteToCRT;
  253.   SetWindowModes (CursorOffMode);
  254.   MakeWindow ( 7,42,17,32,Black+LightGrayBG,Black+LightGrayBG,HDoubleBrdr,
  255.               Window4);
  256.   TitleWindow (Top,Left  ,SameAttr,'4');
  257.   TitleWindow (Top,Center,SameAttr,' Fixed Window ');
  258.   WWriteC ( 1,'DYNAMIC UPDATING!!');
  259.   WBrdrH  ( 2);
  260.   WWriteC ( 3,'Instructions:');
  261.   TWS.WSLine := SingleBrdr;
  262.   WLineH  ( 4,3,TWS.Wcols-4);
  263.   WWrite  ( 5,3, 'ESC - Hide top window');
  264.   WWrite  ( 6,3, 'F5  - Zoom virtual window');
  265.   WWrite  ( 7,3, 'F10 - Quit');
  266.   WWrite  ( 8,3, 'Alt:1-4 - Access window');
  267.   WWrite  ( 9,3, 'With ScrollLock on:');
  268.   WWrite  (10,5,   'R - Resize mode');
  269.   WWrite  (11,5,   'S - Scroll mode');
  270.   WWrite  (12,5,   'M - Move   mode');
  271.   WWrite  (13,5,   'Then arrow keys.');
  272.   WWrite  (14,3, 'Ctrl-NumLock to freeze.');
  273.   WWrite  (15,3, 'Any other key to pause.');
  274.   WGotoRC (TWS.Wrows,1);
  275.   ChangeBorder (DoubleBrdr);
  276. end;
  277.  
  278. begin
  279. { Qsnow := false; }
  280.   Keyb.AddrKbdIdle := @KbdIdle;   { Set hook for KbdIdle routine! }
  281.   Keyb.UseInt9handler (true );    { Set to true for solid keyboard action. }
  282.                                   { Use false for debugging. }
  283.   CreateScreen;
  284.   Line:=1;
  285.   Name:=Window1;
  286.  
  287.   repeat
  288.     Keyb.ReadKbd (Key,ExtKey,Typematic);
  289.     if ScrollLockOn then
  290.       AlterWindow;
  291.     if ExtKey then
  292.       case Key of
  293.         Alt1..Alt4:
  294.           begin
  295.             RestoreBorder;
  296.             AccessWindow (WindowNames (ord(Key)-pred(ord(Alt1))) );
  297.             ChangeBorder (DoubleBrdr);
  298.           end;
  299.         F5Key: VZoomWindow;
  300.       end
  301.     else
  302.       case Key of
  303.         EscKey: begin
  304.                   HideWindow;
  305.                   ChangeBorder (DoubleBrdr);
  306.                 end;
  307.       end;
  308.   until ExtKey and (Key=F10Key);
  309.  
  310.   AccessWindow (Window0);
  311.   WClrScr;
  312.   SetCursor (CursorInitial);
  313. end.
  314.